package com.ruoyi.security.common;

import lombok.Data;

/**
 * 响应类
 */
@Data
public class R<T> {
    private Integer code; //编码：200成功，500失败

    private String msg; //提示信息/错误信息

    private T data; //数据


    public static <T> R<T> ok(T object) {
        R<T> r = new R<T>();
        r.data = object;
        r.code = 200;
        return r;
    }


    public static <T> R<T> ok(T object,String msg) {
        R<T> r = new R<T>();
        r.data = object;
        r.msg =msg;
        r.code = 200;
        return r;
    }

    public static <T> R<T> error(String msg) {
        R r = new R();
        r.msg = msg;
        r.code = 500;
        return r;
    }

}
